package com.example.demo.config;
 
import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; 

import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {
	
	    /**
	     * http://localhost:8080/demo/doc.html 
	     * http://localhost:8080/demo/swagger-ui.html
	     */
	    private boolean swaggerEnable=true;
	
	    @Bean
	    public Docket createRestApi() {
	        return new Docket(DocumentationType.SWAGGER_2)
	                .apiInfo(apiInfo())
	                .enable(swaggerEnable)
	                .select()
	                .apis(RequestHandlerSelectors.basePackage("com.example.demo.controller"))
	                .paths(PathSelectors.any())
	                .build();
	    }	    
	     
		private ApiInfo apiInfo() {
	        return new ApiInfoBuilder()
	                .title("图书管理系统示例--基础数据API说明文档")
	                .description("2026.11.27上线版本")
	                .termsOfServiceUrl("http://github.com")
	                .contact(new Contact("凌云工作室", "http://lingyun.com.cn", "wxdongtt2007@126.com"))
	                .version("1.5.0")
	                .build();
	    } 

}